/*
 * rgbled.c
 *
 *  Created on: 24-10-2012
 *      Author: Skeith
 */

#include "rgbled.h"

void LedInit(void)
{
	IODIR |= LED_IODIR;
	LedClr();
}

void LedClr(void)
{
	IOSET |= LED_PINS;
}

void LedSet(enum LED_COLOR led)
{
	LedClr();

	if(led == RED)
	{
		IOCLR |= LED_R;
	}

	if(led == GREEN)
	{
		IOCLR |= LED_G;
	}

	if(led == BLUE)
	{
		IOCLR |= LED_B;
	}
}

void LedTest(void)
{
	volatile tU32 count, count_max = 1000000;
	volatile tU8 i;

	LedClr();

	for(i = 0; i < 3; i++)
	{
		LedSet(RED);
		for (count = 0; count < count_max; count++);

		LedSet(GREEN);
		for (count = 0; count < count_max; count++);

		LedSet(BLUE);
		for (count = 0; count < count_max; count++);
	}
}
